package com.thesis.service.impl;

import com.github.pagehelper.Page;
import com.thesis.dao.RecordMapper;
import com.thesis.entity.Food;
import com.thesis.entity.Record;
import com.thesis.service.RecordService;
import org.springframework.stereotype.Service;
import org.w3c.dom.stylesheets.LinkStyle;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class RecordServiceImpl implements RecordService {

    @Resource
    private RecordMapper recordMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return recordMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Record Record) {
        return recordMapper.insert(Record);
    }

    @Override
    public int insertSelective(Record Record) {
        return recordMapper.insertSelective(Record);
    }

    @Override
    public Record selectByPrimaryKey(Long id) {
        return recordMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Record Record) {
        return recordMapper.updateByPrimaryKeySelective(Record);
    }

    @Override
    public int updateByPrimaryKey(Record Record) {
        return recordMapper.updateByPrimaryKey(Record);
    }

    @Override
    public List<Record> findPageList(Record Record) {
        return recordMapper.findPageList(Record);
    }

    @Override
    public Page<Record> findPageListByVague(Record queryParam, String vagueParam) {
        return recordMapper.findPageListByVague(queryParam,vagueParam);
    }

    @Override
    public Integer deleteBatchByIds(List<Integer> idList) {
        return recordMapper.deleteBatchByIds(idList);
    }

    @Override
    public void saveOrUpdate(Record Record) {
        if(null == Record.getId()){
            recordMapper.insert(Record);
        } else {
            recordMapper.updateByPrimaryKey(Record);
        }
    }

    @Override
    public List<Record> findAll() {
        return recordMapper.selectAll();
    }

    @Override
    public List<Record> selectClassListByProId(Long proId) {
        return recordMapper.selectClassListByProId(proId);
    }

    @Override
    public List<Map<String, Object>> findAllByTime(String userId) {
        return recordMapper.findAllByTime(userId);
    }

    @Override
    public List<Food> findList(Record record) {
        return recordMapper.findList(record);
    }

    @Override
    public List<Map<String, Object>> findAllByFood(String userId) {
        return recordMapper.findAllByFood(userId);

    }
}
